import axios from 'axios'
import baseUrl from '@/baseUrl'
export default {
  name: 'Home',
  created () {
    axios.get(`${baseUrl}/list`).then((res) => {
      this.datalist = res.data
    })
  },
  computed: {
    roleType () {
      // roleType标志
      return JSON.parse(decodeURI(localStorage.getItem('userinfo'))).roleType * 1 > 1
    }
  },
  methods: {
    colOpenOff () {
      this.colClass = this.colClass === 'col-open' ? 'col-off' : 'col-open'
      this.mLeftColClass = this.mLeftColClass === 'm-l-open' ? 'm-l-off' : 'm-l-open'
      this.mRightCol = this.mRightCol === 'm-r-open' ? 'm-r-off' : 'm-r-open'
    },
    sideActive (idx, val) {
      const arr0 = []; const arr1 = []
      for (const i in this.sideMenu) {
        arr0[i] = ''
        arr1[i] = ''
        if (i === idx) {
          arr0[i] = true
          arr1[i] = val
        }
      }
      this.sideMenu = arr0
      this.sideSub2 = arr1
    },
    logout () {
      localStorage.removeItem('isLogin')
      this.$router.push('/login')
    }
  },
  components: {
  },
  data () {
    return {
      colClass: 'col-open',
      mLeftColClass: 'm-l-open',
      mRightCol: 'm-r-open',
      sideMenu: [true, ''],
      sideSub2: [true, ''],
      datalist: null
    }
  }
}
